

let tree = [
    {
        id:1,
        title:'主页',
        children:[
            {
                id:3,
                title:"主页one",
                pid:1
            },
            {
                id:2,
                title:"主页two",
                pid:1,
                children:[
                    {
                        id:5,
                        pid:2,
                        title:"主页twoone"
                    }
                ]
            },
            
        ]
    },
    {
        id:2,
        title:'次页',
        children:[
            {
                id:3,
                pid:2,
                title:"cone"
            }
        ]
    }
]


function bphmodel(data){
    let newarr = []

    function blxh(data){
        data.forEach(item=>{
            if(item.children){
                blxh(item.children)
            }
                newarr.push({
                    id:item.id,
                    title:item.title,
                    pid:item.pid ?? ""
                })
            
        })
    }
    blxh(data)
    return newarr
}

let res = bphmodel(tree)
// console.log(res);


function zzhus(datata){
    let shuu = []

    datata.forEach(item =>{
        let ress = datata.find(v => item.pid === v.id)
        // console.log(ress);
    })

}

zzhus(res)